// pages/goods/goods-orderInfo.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {

    info: ['', '', ]

  },

  bindPhone(e) {
    wx.makePhoneCall({
      phoneNumber: this.data.store.phone,
    })
  },

  bindAdd(e) {
    const that = this;
    wx.openLocation({
      latitude: parseFloat(that.data.store.lat),
      longitude: parseFloat(that.data.store.lng),
      scale: that.data.store.phone,
      name: that.data.store.name,
      address: that.data.store.address,
    })
  },

  goIndex(e) {
    wx.switchTab({
      url: '../index/index',
    })
  },

  bindShouhuo(e) {
    const that = this;
    wx.showLoading({
      title: '玩命加载中',
      mask: true,
    })
    wx.request({
      url: app.globalData.url + 'Shouhuo',
      data: {
        oid: that.options.oid,
      },
      method: 'POST',
      success: function (res) {
        that.getOrderinfo()
        wx.hideLoading()
      },
    })
  },


  getOrderinfo(e) {
    const that = this;
    wx.showLoading({
      title: '玩命加载中',
      mask: true,
    })
    wx.request({
      url: app.globalData.url + 'Orderinfo',
      data: {
        oid: that.options.oid,
        uid: app.globalData.uid,
      },
      method: 'POST',
      success: function (res) {
        if (res.data.info) {
          that.setData({
            orderinfo: res.data.info,
            goods: res.data.info.goods,
            store: res.data.info.store,
            add: res.data.info.address,
          })
        }
        wx.hideLoading()
      },
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    const that = this;
    that.getOrderinfo()
    wx.stopPullDownRefresh();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    const that = this;
    if (that.options.integral == 1) {
      wx.navigateBack({
        delta: 1
      })
    }
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.getOrderinfo()
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})